package cn.stylefeng.guns.modular.system.controller.ActivityUtil;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.InitBinder;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 全局绑定参数类型
 * @Author : xiaofei
 * @Date: 2019/8/6
 */
@ControllerAdvice
public class Utils {

     @InitBinder
      public void  initBinder(WebDataBinder binder){
           binder.registerCustomEditor(String.class,new StringTrimmerEditor(true));
           binder.registerCustomEditor(Date.class,new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"),false));
      }
}
